Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add config for controlling node ip resolution ordering #131

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mini-ninja-64
Copy link

@mini-ninja-64 mini-ninja-64 commented Nov 6, 2024

Hello,

During node discovery, when ZDM proxy finds an entry present in both system.peers and system.local it currently will always prefer node IP addresses returned by system.local. Some Cassandra implementations handle system.local & system.peer tables differently, when the system.peer table contains ALL nodes in the cluster and the ip addresses from system.local are invalid or should not be used then zdm-proxy will currently not work.

This PR adds 2 new config properties (both defaulting to true, to maintain backwards compatability):

  • OriginPreferIpFromSystemLocal - Sets origin clusters to prefer IP address from system.local
  • TargetPreferIpFromSystemLocal - Sets target clusters to prefer IP address from system.local

These can be used to control the resolution order of IP addresses and would allow for DataStax customers to better migrate from other Cassandra providers.

I am putting this PR out in its current form as an initial conversation starter, I am more than happy to add test coverage for this change, or make other changes, if it is a feature DataStax approves of.

@joao-r-reis
Copy link
Collaborator

Hi can you help us understand the issue first? So you're having an issue where the local node is on both system.local and system.peers but the IP address of that node is only valid in system.peers? How can we reproduce this scenario? Which Cassandra implementations/providers implement this logic?

@mini-ninja-64
Copy link
Author

Hi can you help us understand the issue first? So you're having an issue where the local node is on both system.local and system.peers but the IP address of that node is only valid in system.peers? How can we reproduce this scenario? Which Cassandra implementations/providers implement this logic?

Of course! Thank you so much for looking into this, apologies for my delay in response.

As far as I am aware, "AWS Keyspaces" is the only Cassandra implementation with this quirk, they currently present all IPs in the system.local table as 127.0.0.1, fwiw they have a small note about this behaviour in their documentation.

Because of this to get the external IP of a current node in AWS Keyspaces you must use the system.peers table which also includes the current host. Currently AWS Keyspaces when used with ZDM Proxy will fail as during node discovery the 127.0.0.1 IP from system.local will replace the IP used for a node in ZDM Proxy, as 127.0.0.1 is not likely to be a valid Cassandra ZDM Proxy will fail to resolve any queries for the node.

@mini-ninja-64 mini-ninja-64 force-pushed the host-ip-resolution-config branch from ea3b34f to a830f37 Compare December 23, 2024 11:24
Copy link
Collaborator

@joao-r-reis joao-r-reis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good but ideally we'd also have a test to make sure there is no regression in the future.

Maybe we can leverage the inmemory test client and test server that we have on the integration tests for this. Here's an example. You'll have to create a custom request handler so you can override the ip addresses that are returned, I think the default handler created by func NewSystemTablesHandler doesn't work for this test case because it doesn't allow for a custom address in system.local and always returns an empty system.peers result.

} else if peersListContainsLocalHost {
log.Warnf("Local host is also on the peers list, the peers list will be used as the source of truth: %v vs %v, ignoring the latter one.", peersListLocalHost, localHost)
} else {
log.Tracef("Local host is not on the peers list, it will be added: %v.", localHost)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd change this to DEBUG level

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants